CXX = g++
CXXFLAGS_DEBUG = -Wall -g
CXXFLAGS_RELEASE = -Wall -O2

# 找到所有 .cpp 文件
SOURCES = $(wildcard *.cc)

# 目标文件列表
OBJECTS = $(SOURCES:.cc=.o)

# 可执行文件名称
EXECUTABLE = main

# 默认目标
default: debug

# 编译规则
release: CXXFLAGS = $(CXXFLAGS_RELEASE)
release: $(EXECUTABLE)

debug: CXXFLAGS = $(CXXFLAGS_DEBUG)
debug: $(EXECUTABLE)

$(EXECUTABLE): $(OBJECTS)
	$(CXX) $(CXXFLAGS) -o $@ $^

# 编译目标文件
%.o: %.cc
	$(CXX) $(CXXFLAGS) -c $< -o $@

# 清理规则
clean:
	rm -f $(EXECUTABLE) $(OBJECTS)